package com.bawei.library_base.room.address;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * @author : zhiyu
 * @date : 2021/12/22
 * @content :
 */
@Database(entities = {Address.class},version = 1,exportSchema = false)
public abstract class AddressDatabase extends RoomDatabase {
    private static final String DB_NAME="address.db";
    private static volatile AddressDatabase instance;

    public synchronized static AddressDatabase getInstance(Context context){
        if (instance==null){
            instance= Room.databaseBuilder(
                    context,
                    AddressDatabase.class,
                    DB_NAME).allowMainThreadQueries().build();
        }
        return instance;
    }

    public abstract AddressDao getAddressDao();
}
